package com.xw.Handler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author 郭飞鹏
 * @date 2017年4月21日 上午11:15:01
 * 全局异常处理类 适用于 request to response 这种chain型的请求应答模式
 */
@Component
public class GrobalExceptionHandler implements HandlerExceptionResolver {
	private static Logger logger = LoggerFactory.getLogger(GrobalExceptionHandler.class);
	@Override
	public ModelAndView resolveException(HttpServletRequest arg0,
			HttpServletResponse arg1, Object arg2, Exception e) {
		if(e instanceof NullPointerException){
			logger.error("ERROR : 出现空指针异常", e);
		}
		// TODO 根据需要可以继续完善
		return null;
	}

}
